]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
SearchDisplay: handle certain result IDs specially
authorGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 29 May 2013 20:48:30 +0000 (22:48 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 14 Oct 2013 16:47:20 +0000 (18:47 +0200)
Allow the prefix 'special:' applied to result IDs to mark results
that should be always shown, even when they would overflow the
maximum results cap. This will be used by epiphany for the special
"Search the Web" result.

https://bugzilla.gnome.org/show_bug.cgi?id=707055

js/ui/appDisplay.js
js/ui/remoteSearch.js
js/ui/searchDisplay.js
js/ui/wanda.js

index 52d7b70ae1e59c98f0aef912da2f880623fb66f1..f9c585982ad95b821c25b8041e8bc1d58e70d37b 100644 (file)
@@ -877,6 +877,10 @@ const AppSearchProvider = new Lang.Class({
         callback(metas);
     },
 
+    filterResults: function(results, maxNumber) {
+        return results.slice(0, maxNumber);
+    },
+
     getInitialResultSet: function(terms) {
         this.searchSystem.setResults(this, this._appSys.initial_search(terms));
     },
index b1f485e137e59985d8d887cfacb42c07e6a50d40..f48a37fa5d6578233711e34cc864843f40a46623 100644 (file)
@@ -207,6 +207,16 @@ const RemoteSearchProvider = new Lang.Class({
                              icon_size: size });
     },
 
+    filterResults: function(results, maxNumber) {
+        if (results.length <= maxNumber)
+            return results;
+
+        let regularResults = results.filter(function(r) { return !r.startsWith('special:'); });
+        let specialResults = results.filter(function(r) { return r.startsWith('special:'); });
+
+        return regularResults.slice(0, maxNumber).concat(specialResults.slice(0, maxNumber));
+    },
+
     _getResultsFinished: function(results, error) {
         if (error)
             return;
index 69c79a1af674e369ca1709525fed340afed25158..8ae97abbaaa85be5d387820bd5395b3e77ed2956 100644 (file)
@@ -230,7 +230,7 @@ const SearchResultsBase = new Lang.Class({
             callback();
         } else {
             let maxResults = this._getMaxDisplayedResults();
-            let results = providerResults.slice(0, maxResults);
+            let results = this.provider.filterResults(providerResults, maxResults);
             let hasMoreResults = results.length < providerResults.length;
 
             this.provider.getResultMetas(results, Lang.bind(this, function(metas) {
index 731a631094aa3a1556d7eb38753d9171501aab34..6ed23876636b9e5b64c44ac573fbcc10dd795cb9 100644 (file)
@@ -132,6 +132,10 @@ const WandaSearchProvider = new Lang.Class({
                   }]);
     },
 
+    filterResults: function(results) {
+        return results;
+    },
+
     getInitialResultSet: function(terms) {
         if (terms.join(' ') == MAGIC_FISH_KEY) {
             this.searchSystem.setResults(this, [ FISH_NAME ]);